package com.ews.onlineexchange.controller;

import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.Sector;
import com.ews.onlineexchange.service.EntityQuery;

@Model
public class RootSectorList extends EntityQuery<Sector> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public RootSectorList() {
		setMaxResults(null);
	}

	@Override
	protected List<Predicate> getRestrictions(CriteriaBuilder cb, Root<Sector> entity) {
		List<Predicate> restrictions = super.getRestrictions(cb, entity);
		restrictions.add(cb.isNull(entity.get("parentSector")));
		return restrictions;
	}
	
}
